Page({
  data: {
    questionList: [
      { question: "如何注册账号？", answer: "点击首页右上角注册按钮，填写信息即可。", showAnswer: false },
      { question: "忘记密码怎么办？", answer: "在登录页点击忘记密码，按照提示重置。", showAnswer: false },
      { question: "如何联系管理员？", answer: "进入“设置”页，有管理员联系方式。", showAnswer: false }
    ]
  },

  toggleAnswer(e) {
    const index = e.currentTarget.dataset.index;
    const list = this.data.questionList.map((item, i) => {
      if (i === index) {
        item.showAnswer = !item.showAnswer;
      }
      return item;
    });
    this.setData({ questionList: list });
  }
});
